<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>

let metrodates = ["2008-01","2008-02","2008-03"];
let figures = [0,0.555,0.293]

// 想要这样的结果

let result = [
{data: 0, date: "2008-01"},
{data: 0.555, date: "2008-02"},
{data: 0.293, date: "2008-03"}
]
// 方案一
let result = [];
for(let index in metrodates){
    result.push({data: figures[index], date: metrodates[index]});
}
// 此方案为最原始方法，简单，但过于low
// 方案二

let result = metrodates.map((date,i) => ({date, data: figures[i]}));
// 此方案使用了ES6中的map，简洁，但本质还是遍历，显得有些low

// 方案三
const zip = ([x,...xs], [y,...ys]) => {
if (x === undefined || y === undefined)
     return [];
   else
     return [[x,y], ...zip(xs, ys)];
 }
let result = zip(metrodates, figures).map(([date, data]) => ({date, data}));
// 此方案使用了ES6+递归，显得高大上起来了

// 方案四
const isEmpty = xs => xs.length === 0;
const head = ([x,...xs]) => x;
const tail = ([x,...xs]) => xs; 
const map = (f, ...xxs) => {
let loop = (acc, xxs) => {
     if (xxs.some(isEmpty))
       return acc;
     else
       return loop([...acc, f(...xxs.map(head))], xxs.map(tail));
   };
   return loop([], xxs);
 }
let result = map((date, data) => ({date, data}), metrodates, figures);
</script>
</html>